class CreateUsers < ActiveRecord::Migration
  def self.up
      create_table :users do |t|
        t.string    :login,               :null => false
        t.integer   :msisdn,               :null => false
        t.string    :crypted_password,    :null => false
        t.string    :password_salt,       :null => false
        t.string    :persistence_token,   :null => false
        t.integer   :state,               :null => false, :default => 1, :limit => 1

        # magic fields (all optional, see Authlogic::Session::MagicColumns)
        t.integer   :login_count,         :null => false, :default => 0
        t.integer   :failed_login_count,  :null => false, :default => 0
        t.datetime  :last_request_at
        t.datetime  :current_login_at
        t.datetime  :last_login_at
        t.string    :current_login_ip
        t.string    :last_login_ip

        # fields for game
        t.integer   :amount,         :null => false, :default => 0
        t.integer   :diamond,        :null => false, :default => 0
        t.integer   :bought_diamond, :null => false, :default => 0
        t.integer   :lavel,          :null => false, :default => 1
        t.integer   :practice,       :null => false, :default => 0

        t.string    :name
        t.string    :city
        t.datetime  :birthday

        # fields for ROLES
        t.integer   :admin,           :null => false, :default => 0
        t.integer   :moderator,       :null => false, :default => 0
        t.integer   :gamer,           :null => false, :default => 1

        t.timestamps
      end
      add_index :users, :admin
      add_index :users, :gamer
      add_index :users, :moderator
      add_index :users, :lavel
      add_index :users, :amount
      add_index :users, :diamond
      add_index :users, :bought_diamond
      add_index :users, :practice
      add_index :users, :state
      add_index :users, ["login"], :name => "index_users_on_login", :unique => true
      add_index :users, ["msisdn"], :name => "index_users_on_msisdn", :unique => true
      add_index :users, ["persistence_token"], :name => "index_users_on_persistence_token", :unique => true

    end

    def self.down
      drop_table :users
    end
end

